# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Síle Ekaterin Liszka <sheila@vulpine.house>
# Maintainer: Síle Ekaterin Liszka <sheila@vulpine.house>
pkgname=nheko
pkgver=0.11.3
pkgrel=7
pkgdesc="Qt5-based client for Matrix protocol"
url="https://github.com/Nheko-Reborn/nheko"
# armhf blocked by qt5-qtmultimedia
# riscv64: ftbfs
arch="all !armhf !riscv64"
license="GPL-3.0-or-later"
options="!check" # no test suite
depends="
	dbus:org.freedesktop.Secrets
	libsecret
	libnice-gstreamer
	qt5-qtquickcontrols2
	so:libgstcompositor.so
	so:libgstdtls.so
	so:libgstopengl.so
	so:libgstopus.so
	so:libgstrtp.so
	so:libgstrtpmanager.so
	so:libgstsrtp.so
	so:libgstvpx.so
	so:libgstwebrtc.so
	"
makedepends="
	asciidoctor
	boost-dev
	cmake
	cmark-dev
	gst-plugins-bad-dev
	gst-plugins-base-dev
	gstreamer-dev
	lmdb-dev
	lmdbxx
	mtxclient-dev
	nlohmann-json
	olm-dev
	openssl-dev>3
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	qt5-qtmultimedia-dev
	qt5-qtquickcontrols2-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	qtkeychain-dev
	samurai
	spdlog-dev
	tweeny
	xcb-util-wm-dev
	zlib-dev
	"
subpackages="$pkgname-doc $pkgname-zsh-completion"
source="$pkgname-$pkgver.tar.gz::https://github.com/Nheko-Reborn/nheko/archive/v$pkgver.tar.gz
	0001-Fix-build-against-fmt10.patch
	0001-Fix-build-with-fmt-10.1.0.patch
	gcc13.patch
	"

prepare() {
	default_prepare
	sed -e '/-Werror/d' \
		-i CMakeLists.txt
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	LDFLAGS="$LDFLAGS -Wl,-z,stack-size=1048576" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_SKIP_RPATH=True \
		-DCMAKE_BUILD_TYPE=None \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ninja -C build check
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
bd5b94def3c56bb2c91c40c3ef967ee3b14cb71a7e5b01028743a849932c918620c2b1a1b822705e49dacc80dae6c48712f63bf9a68698858b0faaf1a816c9cd  nheko-0.11.3.tar.gz
1376ee0d439a19cc454e88657a6d591a7906d22531cc6d943f62beeb34de85b7235b94f3095f8c0d159af520460d0ae9845342f1b24d026bbe3d7f4f99cafc68  0001-Fix-build-against-fmt10.patch
c07bad9c0d63bbaf307a5915a364a3c32e649a3ff5b9aa25070e95f590cad262f4c26f09a3c6394d8481e33bac3355da02ef649fca018f4872a8ff0b4f9a7c9c  0001-Fix-build-with-fmt-10.1.0.patch
0253d52fa432c8656688281358dbdeefac77df11e823a602dacb9a8a7df5c8cc0c3576f9e4f4d50e0a72607bb8fab6505a3219801320f730dbfd8a48cad48e98  gcc13.patch
"
